package com.rightsidetech.commom.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.Serializable;

/**
 * @Package: com.rightsidetech.http.config
 * @ClassName: OSSConfig
 * @Author: yinj
 * @CreateTime: 2021/6/1 10:56
 * @Description: 阿里云OSS存储配置
 */
@Data
@Configuration
public class AliyunOSSConfig implements Serializable {

    // 地域节点
    @Value("${aliyun.oss.endpoint}")
    private String endpoint;
    @Value("${aliyun.accessKeyId}")
    private String accessKeyId;
    @Value("${aliyun.accessKeySecret}")
    private String accessKeySecret;

    @Value("${aliyun.oss.bucketName}")
    private String bucketName;
    @Value("${aliyun.oss.urlPrefix}")
    private String urlPrefix;
    @Value("${aliyun.oss.imageUrl}")
    private String imageUrl;

    @Bean
    public OSS ossClient() {
        return new OSSClientBuilder().build(endpoint,accessKeyId,accessKeySecret);
    }

}
